﻿Public Class DoubleRectangle

    Public Function Contains(block As Block) As Boolean
        Return Me.Contains(block.X, block.Y)
    End Function

    Public Function Contains(x As Int32, y As Int32) As Boolean
        Return ((((Me.X <= x) And (x < (Me.X + Me.Width))) And (Me.Y <= y)) And (y < (Me.Y + Me.Height)))
    End Function

    Public Function Contains(pt As Point) As Boolean
        Return Me.Contains(pt.X, pt.Y)
    End Function

    Public Sub New(pt As Point, sz As Size)
        Me.Location = pt
        Me.Size = sz
    End Sub

#Region "Properties"

    Private _x As Integer
    Public Overridable Property X() As Integer
        Get
            Return _x
        End Get
        Set(ByVal value As Integer)
            _x = value
            _l = New Point(value, Y)
        End Set
    End Property

    Private _y As Integer
    Public Property Y() As Integer
        Get
            Return _y
        End Get
        Set(ByVal value As Integer)
            _y = value
            _l = New Point(X, value)
        End Set
    End Property

    Private _w As Integer
    Public Property Width() As Integer
        Get
            Return _w
        End Get
        Set(ByVal value As Integer)
            _w = value
            _s = New Size(value, Height)
        End Set
    End Property

    Private _h As Integer
    Public Property Height() As Integer
        Get
            Return _h
        End Get
        Set(ByVal value As Integer)
            _h = value
            _s = New Size(Width, value)
        End Set
    End Property

    Private _l As Point
    Public Property Location() As Point
        Get
            Return _l
        End Get
        Set(ByVal value As Point)
            _l = value
            _x = value.X
            _y = value.Y
        End Set
    End Property

    Private _s As Size
    Public Property Size() As Size
        Get
            Return _s
        End Get
        Set(ByVal value As Size)
            _s = value
            _h = value.Height
            _w = value.Width
        End Set
    End Property

#End Region

End Class
